package zhongbo.java.air.common.vo;

import lombok.Data;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2025年03月17日 星期一 22:12:06
 */
@Data
public class ResultVo<T> {

    private int code;

    private String msg;

    private T data;

    public static <T> ResultVo<T> success() {
        ResultVo<T> ResultVo = new ResultVo<>();
        ResultVo.setCode(0);
        return ResultVo;
    }

    public static <T> ResultVo<T> ok(T data) {
        ResultVo<T> ResultVo = new ResultVo<>();
        ResultVo.setCode(0);
        ResultVo.setData(data);
        return ResultVo;
    }

    public static <T> ResultVo<T> failed() {
        ResultVo<T> ResultVo = new ResultVo<>();
        ResultVo.setCode(-1);
        return ResultVo;
    }

    public static <T> ResultVo<T> error(String msg) {
        ResultVo<T> ResultVo = new ResultVo<>();
        ResultVo.setCode(-1);
        ResultVo.setMsg(msg);
        return ResultVo;
    }

    public static <T> ResultVo<T> wrong(Integer code, String errorMsg) {
        ResultVo<T> ResultVo = new ResultVo<>();
        ResultVo.setCode(code);
        ResultVo.setMsg(errorMsg);
        return ResultVo;
    }
}
